package com.example.demo.story.impl;

import com.example.demo.story.NetStoryServiceAbstract;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.util.Objects;

/**
 * @Author TCJ
 * @create 2024/6/11
 */
public class Yqsm extends NetStoryServiceAbstract {
	@Override
	public String getBaseUrl() {
		return "https://www.yqxsmf.com/";
	}

	@Override
	public String getReadUrl() {
		return getBaseUrl() +  "ea/114463/";
	}

	@Override
	public void analysisChapter() {
		Document html = super.getHtml(getReadUrl());
		Element list = html.body().getElementById("list");
		if (list == null){
			return;
		}
		Elements dd = list.getElementsByTag("dd");
		dto.setTitle("打的----");
		dd.forEach(item ->{
			Elements a = item.getElementsByTag("a");
			super.dto.getChapter().put(a.text(), "https:" + a.attr("href"));
		});
	}

	@Override
	public String getContent(String url) {
		Document html = super.getHtml(url);
		return Objects.requireNonNull(html.body().getElementById("content")).text();
	}
}
